package service.impl;

import dao.impl.AirInfoDaoImpl;

import java.util.*;
import java.util.Scanner;

public class AirInfoServiceImpl {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        System.out.println("————————————————————————————————————————————————欢迎使用航班信息管理系统————————————————————————————————————————————————");
        while (true){
            System.out.println("\n请选择操作：（1、列出所有航班，2、按起飞时间查询，3、按目的地查询，4、删除航班，5、更新航班，6、航班留言，0、离开）");
            int userSelect = Integer.parseInt(sc.nextLine());
            AirInfoDaoImpl airInfoDao = new AirInfoDaoImpl();
            switch (userSelect) {
                case 1:
                    airInfoDao.getAll();
                    break;
                case 2:
                    airInfoDao.getByDate(inPut());
                    break;
                case 3:
                    airInfoDao.getByCity(inPut());
                    break;
                case 4:
                    airInfoDao.deleteById(inPut2());
                    break;
                case 5:
                    airInfoDao.updateById(inPut3());
                    break;
                case 6:
                    airInfoDao.setById(inPut4());
                    break;
                case 0:
                    System.exit(0);
                    break;
            }
        }
    }
    public static String inPut(){
        System.out.println("请输入所要查询的航班信息：");
        return sc.nextLine();
    }
    public static int inPut2(){
        System.out.println("请输入所要删除的航班编号：");
        return Integer.parseInt(sc.nextLine());
    }
    public static List inPut3(){
        System.out.print("请输入所要更新的航班编号：");
        int airId = Integer.parseInt(sc.nextLine());
        System.out.print("请输入新的航班号：");
        String airName = sc.nextLine();
        System.out.print("请输入新的目的地：");
        String airCity = sc.nextLine();
        System.out.print("请输入新的起飞日期：");
        String airDate = sc.nextLine();
        List list = new ArrayList();
        list.add(airName);
        list.add(airCity);
        list.add(airDate);
        list.add(airId);
        return list;
    }
    public static List inPut4(){
        System.out.println("请选择所要留言的航班编号：");
        int airId = Integer.parseInt(sc.nextLine());
        System.out.println("请输入留言内容（不超过20字）：");
        String airWord = sc.nextLine();
        List list = new ArrayList();
        list.add(airWord);
        list.add(airId);
        return list;
    }
}
